package com.todo.content.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.content.application.backend.service.ContentClassifyBackendService;
import com.todo.content.iface.backend.ContentClassifyBackendIface;
import com.todo.content.iface.backend.request.*;
import com.todo.content.iface.backend.response.ContentClassifyDetailByIdResp;
import com.todo.content.iface.backend.response.QueryContentClassifyByConditionResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/7/5 11:42
 * @description
 */
@RestController
@RequestMapping("/bd/content/classify")
@Tag(name = "内容分类后台处理类", description = "内容分类后台处理类")
public class ContentClassifyBackendController implements ContentClassifyBackendIface {

    @Resource
    private ContentClassifyBackendService contentClassifyBackendService;

    @Override
    @Operation(summary = "新增内容分类信息")
    @PostMapping("/insertContentClassify")
    public BizResponse<Boolean> insertContentClassify(@RequestBody InsertContentClassifyReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentClassifyBackendService.insertContentClassify(req);
    }

    @Override
    @Operation(summary = "根据主键更新内容分类信息")
    @PostMapping("/updateContentClassifyById")
    public BizResponse<Boolean> updateContentClassifyById(@RequestBody UpdateContentClassifyByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentClassifyBackendService.updateContentClassifyById(req);
    }

    @Override
    @Operation(summary = "根据主键删除分类信息")
    @PostMapping("/removeContentClassifyById")
    public BizResponse<Boolean> removeContentClassifyById(@RequestBody RemoveContentClassifyByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentClassifyBackendService.removeContentClassifyById(req);
    }

    @Override
    @Operation(summary = "根据主键启禁用分类信息")
    @PostMapping("/enableContentClassifyById")
    public BizResponse<Boolean> enableContentClassifyById(@RequestBody EnableContentClassifyByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentClassifyBackendService.enableContentClassifyById(req);
    }

    @Override
    @Operation(summary = "根据主键查询分类详情")
    @PostMapping("/queryContentClassifyById")
    public BizResponse<ContentClassifyDetailByIdResp> queryContentClassifyById(@RequestBody QueryContentClassifyByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentClassifyBackendService.queryContentClassifyById(req);
    }

    @Override
    @Operation(summary = "多条件查询分类信息")
    @PostMapping("/queryContentClassifyByCondition")
    public BizPageResponse<QueryContentClassifyByConditionResp> queryContentClassifyByCondition(@RequestBody QueryContentClassifyByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return contentClassifyBackendService.queryContentClassifyByCondition(req);
    }
}
